package com.major;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        Socket socket = new Socket();
        OutputStream outputStream = null;
        try {
            socket.connect(new InetSocketAddress(InetAddress.getLocalHost(),8888));
            Scanner scanner = new Scanner(System.in);
            String s = scanner.next();

            outputStream = socket.getOutputStream();
            outputStream.write(s.getBytes());

            outputStream.flush();

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            try {
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
